/**
 * 分页控件
 * @param  {number} all         defaultValue = 50    [数据总条数]
 * @param  {number} pageConten  defaultValue = 10    [每页数据的条数]
 * @param  {number} pageSize    defaultValue = 05    [分页控件翻页的个数]
 * @param  {number} page        defaultValue = 01    [当前页]
 * @param  {function} pageBarClick                   [切换页事件]
 */
import {LANG} from '../../config/config.js';

class image extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      url: this.props.url || 'http://bpic.588ku.com/back_pic/04/17/50/445827f0456acd1.jpg!/fw/650/quality/90/unsharp/true/compress/true',
      name: this.props.name || '病例图片',
      delete: false
    }

    this.seeClick = this.seeClick.bind(this);
    this.deleteClick = this.deleteClick.bind(this);
  }

  // 查看图片
  seeClick() {
    window.open(this.state.url);
    this.props.seeClick && typeof this.props.seeClick === 'function' && this.props.seeClick();
  }

  // 删除图片
  deleteClick() {
    this.setState({delete: true});
    this.props.deleteClick && typeof this.props.deleteClick === 'function' && this.props.deleteClick();
  }

  render() {
    return (
      <div className={this.state.delete ? "images images-close" : "images"}>
        { this.state.url ? <div style={{backgroundImage:`url(${this.state.url})`}}></div> : ''}
        <span onClick={this.seeClick}>{LANG[Lang].see}</span>
        <span onClick={this.deleteClick}>{LANG[Lang].delete}</span>
      </div>
    )
  }
}

module.exports = image;
